package com.jt.controller;

import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/axios")
@CrossOrigin//专门解决跨域的
public class AxiosController {
    @GetMapping("/findStr")
    public String findStr(){
        return "加油";
    }

    @GetMapping("/getUserById")
    public String getUserById(Integer id){
        return "获取数据"+id;
    }

    /*
    * url:http://localhost:8080/axios/findUser?id=100&name=tomcat
    * */
    @GetMapping("/findUser")
    public User findUser(User user){
        return user;
    }

    /*
    * 接收restful的数据
    * url:http://localhost:8080/axios/result/100/tomcat/19
    * 返回值:user对象*/
    @GetMapping("/result/{id}/{name}/{age}")
    public User result(User user){
        return user;
    }


    @PostMapping("/saveUser")
    public User result2(@RequestBody User user){
        return user;
    }
}
